

package com.hazelcast.client.impl.spi;

import com.hazelcast.transaction.TransactionContext;
import com.hazelcast.transaction.TransactionOptions;
import com.hazelcast.transaction.TransactionalTask;

import javax.annotation.Nonnull;
import javax.transaction.xa.Xid;

/**
 * Manages the execution of client transactions and provides {@link TransactionContext}s.
 * <p>
 * Client equivalent of {@link com.hazelcast.transaction.TransactionManagerService}.
 */
public interface ClientTransactionManagerService {

    <T> T executeTransaction(@Nonnull TransactionalTask<T> task);

    <T> T executeTransaction(@Nonnull TransactionOptions options, @Nonnull TransactionalTask<T> task);

    TransactionContext newTransactionContext();

    TransactionContext newTransactionContext(@Nonnull TransactionOptions options);

    /**
     * @param xid              branch qualifier
     * @param timeoutInSeconds transaction timeout in seconds
     * @return a {@link TransactionContext} for the supplied branch qualifier
     */
    TransactionContext newXATransactionContext(Xid xid, int timeoutInSeconds);

    String getClusterName();
}
